package com.easy.controller;

import com.easy.bean.Admin;
import com.easy.service.ISystemLoginService;
import com.easy.service.impl.SystemLoginService;
import com.easy.util.LayData;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
@Controller
@RequestMapping("admin")
public class AdminController {
    @Autowired
    ISystemLoginService systemLoginService;

    @RequestMapping("list1")
    @ResponseBody
    public LayData getList(Page page, String text) {
        // 管理员查看所有用户信息，不需要用户ID限制
        List<Admin> list = systemLoginService.getList1(page, text);
        int count = systemLoginService.getCount1(text);
        return new LayData(count, list);
    }

    @RequestMapping("add")
    @ResponseBody
    public int add(Admin admin) {
        return systemLoginService.add(admin);
    }

    @RequestMapping("delete")
    @ResponseBody
    public int delete(int adminid) {
        return systemLoginService.delete(adminid);
    }

    @RequestMapping("edit")
    @ResponseBody
    public int edit(Admin admin) {
        return systemLoginService.edit(admin);
    }
}
